var app = getApp();
var https = "https://www.moreclub.cn/";

var add0 = function (m) {
  return m < 10 ? '0' + m : m
}

var time3 = function (shijianchuo) {
  var time = new Date(shijianchuo);
  // var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var h = time.getHours();
  var mm = time.getMinutes();
  var week;
  var day = time.getDay();
  // var s = time.getSeconds();
  switch (day) {
    case 0: week = "周天"; break
    case 1: week = "周一"; break
    case 2: week = "周二"; break
    case 3: week = "周三"; break
    case 4: week = "周四"; break
    case 5: week = "周五"; break
    case 6: week = "周六"; break
  }
  // return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':' + add0(mm) + ':' + add0(s);
  // return add0(h) + ':' + add0(mm)
  //return day; 
  return add0(m) + '月' + add0(d) + '日' + ' ' + week + ' ' + add0(h) + ':' + add0(mm)
}


Page({
  data: {},
  onLoad: function (options) {
    var that = this;
    var w = options.width;
    var mid = options.mid
    wx.request({
      url: https + 'v1/merchant/open/acts/'+mid,
      //dataType: "application/json",
      success: function (res) {
        var actData = res.data.data;
        console.log(res)

        var buslist = [];//创建新商圈列表
        for (var key in actData) {
          var title = actData[key].title;
          var title2 = actData[key].title;
          var introduction = actData[key].introduction;
          var bannerPhoto = actData[key].bannerPhoto;
          var endTime = actData[key].endTime;
          var newtime = new Date().getTime();
          console.log(newtime)
          var iNime = Number(endTime - newtime);
          var shijianchuo = actData[key].startTime;
          var activityId = actData[key].activityId;
          time3(shijianchuo)
          var dataTime = time3(shijianchuo)
         
          var obj = {};
          obj.title = title;
          obj.title2 = title2;
          obj.activityId = activityId;
          obj.introduction = introduction;
          obj.bannerPhoto = bannerPhoto;
          obj.dataTime = dataTime;
          obj.iNime = iNime;
          buslist.push(obj);
        }
        console.log(buslist)

        that.setData({
          actData: actData,
          w: w,
          buslist:buslist
        })
      }
    })

   
  }
})